package com.hssoftvn.android.apps.callmessmoneycontroller.modules;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.hssoftvn.android.apps.callmessmoneycontroller.enums.SConstanst;
import com.hssoftvn.android.apps.callmessmoneycontroller.util.SUtils;

public class TinyPhoneStateListener extends BroadcastReceiver {
	
	@Override
	public void onReceive(Context arg0, Intent data) {
		// TODO Auto-generated method stub
		if (data.getAction().equals(SConstanst.INTENT_ACTION_NOTIFY_OPENCELLID_RESULT)){
			String body="Finally, you got it with data from CellListener:";
			Bundle extras = data.getExtras();
			if (extras!=null){
				if (extras.getBoolean(SConstanst.EXTRA_OPENCELLID_BOOL_HASERROR, false)){
					body += "\nError !!\nCannot have the result!";
				} else {
					int lat = extras.getInt(SConstanst.EXTRA_OPENCELLID_INT_LATITUDE);
					int lon = extras.getInt(SConstanst.EXTRA_OPENCELLID_INT_LONGITUDE);
					body += "("+ lat + "," + lon +")";
				}
				
			}
			body += "";
			SUtils.showDialogMessage("Good Job!", body);
		}
		if (data.getAction().equals("android.provider.Telephony.SMS_RECEIVED")){
			//SUtils.showToastMessage("You have a message: " +data.getDataString());
			SUtils.showDialogMessage("Notice", "You have a message: " +data.getDataString());
		}
		
	}
	
}
